#ifndef __M_LOG_H__
#define __M_LOG_H__

#pragma once

#include <cstdio>
#include <ctime>

#define INF 0
#define DEG 1
#define ERR 2
#define DEFAULT_LEVEL ERR

#define LOG(level, format, ...)\
do {\
    if (level >= DEFAULT_LEVEL)\
    {\
        time_t timer = time(NULL);\
        struct tm* lt = localtime(&timer);\
        char buffer[32] = { 0 };\
        strftime(buffer, sizeof buffer - 1, "[%H:%M:%S]", lt);\
        fprintf(stdout, "%p %s [%s:%d]" format "\n", (void*)pthread_self(), buffer, __FILE__, __LINE__, ##__VA_ARGS__);\
    }\
} while(0)

#endif
